home *** CD-ROM | disk | FTP | other *** search
- Path: ux2.cso.uiuc.edu!shair
- From: rmshair@uiuc.edu (Bob Shair)
- Newsgroups: comp.lang.rexx
- Subject: REXX BEAUTIES: Parse a string of keywords and values
- Date: 3 Apr 1996 21:34:57 GMT
- Organization: University of Illinois at Urbana
- Distribution: inet
- Message-ID: <4juqu1$qpu@vixen.cso.uiuc.edu>
- References: <changi0.9m.29HzgB$07j@engcorp.com>
- NNTP-Posting-Host: ux2.cso.uiuc.edu
- Originator: shair@ux2.cso.uiuc.edu
-
- peter@engcorp.com (Peter Hansen) writes:
- >I like to see the occasional posting with somebody's programming gems,
-
- /* Two neat ideas here: */
- /* This example happens to come from CMS, but I don't think it matters */
-
- parse arg ifid host ofid "(" option_list ")" remainder
- BLOCK=''; LRECL='';
- /* Idea 1:Tearing apart a list of arbitrarily ordered codes and values,*/
- /* e.g. (block 8192 po 2199 A NO) and extracting the values from them */
- do while option_list \= ''
- parse upper var option_list opt val option_list
- select
- when abbrev('BLOCK ',opt,1) then do; bksz=val; BLOCK="BLOCK"; end
- when abbrev('LRECL ',opt,1) then do; lrec=val; LRECL="LRECL"; end
- when abbrev('PORT ',opt,1) then port=val
- when abbrev('HEADERS',opt,1) then headers=val
- when abbrev('ASCII ',opt,1) then ASCII=val
- otherwise do; say 'Invalid option' opt; signal options; end
- end
- end
- /* Idea 2:pre-assigning NULL to variables substituted into a command */
- /* so they only appear if the user specifies the corresponding value */
- 'DYNOPEN TAPEIN DSN' ifid '(TAP1 INPUT' BLOCK bksz LRECL lrec
- --
-
- Bob Shair Open Systems Consultant
- 1018 W. Springfield Avenue rmshair@uiuc.edu
- Champaign, IL 61821 217/356-2684
-